from lib2to3.pgen2 import driver
from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains


driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
driver.maximize_window()
# 左键点击操作 .click()
driver.find_element("id", "kw").send_keys("赵丽颖")
driver.find_element("id", "su").click()

# 右键点击操作 .context_click(元素).perfrom()
ele = driver.find_element("link text", "地图")
ActionChains(driver).context_click(ele).perform()

# 双击操作 .double_click(元素).perfrom
ele = driver.find_element("link text", "地图")
ActionChains(driver).double_click(ele).perform()

# 鼠标拖拽 .drag_and_drop(source, target)
# source: 开始位置，需要拖动的元素
# target: 结束位置，拖到后需要防止的目的地元素
ele1 = driver.find_element("id", "")
ele2 = driver.find_element("id", "")
ActionChains(driver).drag_and_drop(ele1,ele2).perform()

# 鼠标悬停 .move_to_element()
ele = driver.find_element("id", "s-usersetting-top")
ActionChains(driver).move_to_element(ele).perform()


sleep(3)
driver.quit()